package com.jrx.anytxn.reporting.job.xib.step;

import com.jrx.anytxn.reporting.entity.AmlIATrading;
import com.jrx.anytxn.reporting.job.xib.bean.AmlIATradingBean;
import com.jrx.anytxn.reporting.service.IXibService;
import com.jrx.anytxn.transaction.entity.TlPaymentLog;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.batch.item.ItemProcessor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class TradingPaymentProcessor implements ItemProcessor<TlPaymentLog, AmlIATradingBean> {

    @Autowired
    private IXibService xibService;

    private static final Logger logger = LoggerFactory.getLogger(TradingPaymentProcessor.class);


    @Override
    public AmlIATradingBean process(TlPaymentLog item) throws Exception {
        try {
            AmlIATradingBean amlIATradingBean = new AmlIATradingBean();

            List<AmlIATrading> amlIATradings = xibService.assemPaymentTrading(item);

            amlIATradingBean.setAmlIATradingList(amlIATradings);

            return amlIATradingBean;
        } catch (Exception e) {
            e.printStackTrace();
            logger.error("generateTradingJob 出错了：{}", e.getMessage());
        }
        return null;
    }
}
